package com.michael.self.demompchart

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.widget.TextView
import com.github.mikephil.charting.components.MarkerView
import com.github.mikephil.charting.data.CandleEntry
import com.github.mikephil.charting.data.Entry
import com.github.mikephil.charting.highlight.Highlight
import com.github.mikephil.charting.utils.Utils

class MyMarkerView(context: Context, layoutResource: Int) : MarkerView(context, layoutResource) {
    private var tvContent: TextView = findViewById<TextView>(R.id.tvContent)
    private val mPaint= Paint()
    override fun refreshContent(e: Entry?, highlight: Highlight?) {

        if (e is CandleEntry) {
            tvContent.text =
                Utils.formatNumber(e.high, 0, true)
        } else {
            tvContent.text =
                Utils.formatNumber(e!!.y, 0, true)
        }
        super.refreshContent(e, highlight)
    }



    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        mPaint.color=Color.BLACK
        mPaint.strokeWidth=4f
        canvas?.drawLine(0f,height.toFloat(),0f,height.toFloat()+1600f,mPaint)
    }


}